<?php

namespace plugin\muadmin\app\common\model;

use think\Model;

class AuthGroup extends Model
{
    protected $name = 'auth_group';
    protected $autoWriteTimestamp = 'datetime';
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    public function authrule()
    {
        return AuthRule::whereIn('id',$this->rules)->select();
    }
    public function setRulesAttr($value)
    {
        if(!empty($value)){
            if(is_array($value)){
                $value = implode(',',$value);
            }
        }
        return $value;
    }
    public function getRulesAttr($value)
    {
        if(!empty($value)){
            if(is_string($value)){
                $value = explode(',',$value);
            }
        }else{
            $value = [];
        }
        return $value;
    }
}